package com.ibangnuo.manage.controller.order;

import com.ibangnuo.api.order.OrderControllerApi;
import com.ibangnuo.framework.domain.request.count.MoneyCountRequest;
import com.ibangnuo.framework.domain.request.order.OrderQueryCountRequest;
import com.ibangnuo.framework.domain.request.order.OrderQueryGroupRequest;
import com.ibangnuo.framework.domain.request.order.OrderQueryRequest;
import com.ibangnuo.framework.model.response.ObjectResult;
import com.ibangnuo.framework.model.response.QueryResponseResult;
import com.ibangnuo.manage.service.order.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: wwy
 * @Date: 2019-12-31 13:57
 */
@RestController
@RequestMapping("/order")
public class OrderController implements OrderControllerApi {
    @Autowired
    private OrderService orderService;

    /**
     * 分页条件查询
     * @param orderQueryRequest
     * @return
     */
    @PostMapping("/list")
    @Override
    public QueryResponseResult findList(@RequestBody OrderQueryRequest orderQueryRequest) {
        return orderService.findList(orderQueryRequest);
    }

 /**
     * 分页条件查询
     * @param orderQueryRequest
     * @return
     */
    @PostMapping("/listSelect")
    @Override
    public QueryResponseResult findListSelect(@RequestBody OrderQueryRequest orderQueryRequest) {
        return orderService.findListSelect(orderQueryRequest);
    }


    /**
     * 根据时间范围分组查询
     * @param orderQueryGroupRequest
     * @return
     */
    @PostMapping("/queryGroup")
    @Override
    public ObjectResult queryGroup(@RequestBody OrderQueryGroupRequest orderQueryGroupRequest) {
        return orderService.queryGroup(orderQueryGroupRequest);
    }

    /**
     * 后台的汇总
     * @return
     */
    @Override
    @PostMapping("/queryCount")
    public QueryResponseResult queryCount() {
        return orderService.queryCount();
    }
 /**
     * 商户门店汇总查询
     * @return
     */
    @Override
    @GetMapping("/shopCount")
    public QueryResponseResult shopCount(@RequestParam("page") int page,@RequestParam("limit") int limit) {
        return orderService.shopCount(page,limit);
    }

    /**
     * 根据订单id查询
     * @param id
     * @return
     */
    @GetMapping("/findById/{id}")
    @Override
    public ObjectResult findById(@PathVariable("id") String id) {
        return orderService.findById(id);
    }

    @Override
    @GetMapping("/findByOrderId/{id}")
    public QueryResponseResult findByOrderId(@PathVariable("id") String id) {
        return orderService.findByOrderId(id);
    }


}
